package com.musifind.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ListView;

import com.musifind.adapters.SearchAdapterAlbums;
import com.musifind.models.SearchItems;

public class AlbumsFragment extends BaseFragment {

	private ListView lstSearchAlbums;
	static ImageView imgLogo;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_albums, container, false);
		imgLogo = (ImageView) rootView.findViewById(R.id.imgBlankPage);
		searchAdapterAlbums = new SearchAdapterAlbums(getActivity(), R.layout.search_list_items_row_album,
				searchArrayAlbums);
		lstSearchAlbums = (ListView) rootView.findViewById(R.id.lstSearchAlbumItems);
		lstSearchAlbums.setAdapter(searchAdapterAlbums);

		lstSearchAlbums.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				SearchItems item = (SearchItems) searchAdapterAlbums.getItem(position);
				Intent i = new Intent(getActivity(), TracksOfAlbumActivity.class);
				i.putExtra("albumId", item.getAlbumId());
				i.putExtra("albumName", item.getAlbumName());
				startActivity(i);
			}
		});
		return rootView;
	}
}
